/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.edu.kamai.webservice;

import com.edu.kamai.logic.facade.PaperFacade;
import com.edu.kamai.persistence.beans.Paper;
import java.util.Date;
import java.util.List;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;

/**
 *
 * @author xyzhu
 */
@WebService(serviceName = "paperService")
@Stateless()
public class paperService {

    /**
     * Web 服务操作
     */
    @WebMethod(operationName = "addOnePaper")
    public Integer addOnePaper(@WebParam(name = "paperPath")
    String paperPath, @WebParam(name = "paperKey")
    String paperKey, @WebParam(name = "paperTitle")
    String paperTitle, @WebParam(name = "paperDes")
    String paperDes, @WebParam(name = "paperRole")
    int paperRole) {
        //TODO write your implementation code here:
        Paper paperBean = new Paper();
        paperBean.setTitle(paperTitle);
        paperBean.setPaperKey(paperKey);
        paperBean.setPaperPath(paperPath);
        paperBean.setStatus(paperRole);
        paperBean.setDescription(paperDes);
        paperBean.setStartTime(new Date());
        paperBean.setEndTime(null);
        try{
            return PaperFacade.addOnePaper(paperBean);
        }catch(Exception ex){
            ex.printStackTrace();
        }
        return 0;
    }

    /**
     * Web 服务操作
     */
    @WebMethod(operationName = "findPaperByRoleID")
    public List<Paper> findPaperByRoleID(@WebParam(name = "roleID")
    int roleID) {
        //TODO write your implementation code here:
        return PaperFacade.findPaperByRoleID(roleID);
        //return null;
    }

    /**
     * Web 服务操作
     */
    @WebMethod(operationName = "findPaperByIDAndRole")
    public Paper findPaperByIDAndRole(@WebParam(name = "roleID")
    int roleID, @WebParam(name = "pid")
    int pid) {
        //TODO write your implementation code here:
        return PaperFacade.findPaperByIDAndRole(roleID, pid);
    }

    /**
     * Web 服务操作
     */
    @WebMethod(operationName = "findPapers")
    public List<Paper> findPapers() {
        //TODO write your implementation code here:
        return PaperFacade.findPapers();
    }
    
    
}
